package com.xinou.daily_report.controller;


import com.xinou.common.base.config.ApiResponse;
import com.xinou.daily_report.PO.IntegralPO;
import com.xinou.daily_report.VO.integral.IntegralVO;
import com.xinou.daily_report.VO.integral.IntegralCountVO;
import com.xinou.daily_report.VO.integral.IntegralListVO;
import com.xinou.daily_report.service.SysIntegralService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2021-06-11
 */
@RestController
@RequestMapping("/mini/integral")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@Api(tags = {"前台积分"})
public class MiniIntegralController {
    private final SysIntegralService sysIntegralService;

    @PostMapping("/list")
    @ApiOperation("获取积分列表")
    @RequiresPermissions({"mini:integral:list"})
    public ApiResponse<IntegralListVO> integralList(@RequestBody IntegralPO integralPO){
        return sysIntegralService.integralList(integralPO);
    }

    @PostMapping("/count")
    @ApiOperation("获取积分统计")
    @RequiresPermissions({"mini:integral:count"})
    public ApiResponse<IntegralCountVO> integralCount(@RequestBody IntegralPO integralPO){
        return sysIntegralService.integralCount(integralPO);
    }

    @PostMapping("/save")
    @ApiOperation("添加积分")
    @RequiresPermissions({"mini:integral:save"})
    public ApiResponse<Void> integralSave(@RequestBody IntegralPO integralPO){
        return sysIntegralService.integralSave(integralPO);
    }

    @PostMapping("/getById")
    @ApiOperation("根据id查询积分")
    @RequiresPermissions({"mini:integral:getById"})
    public ApiResponse<IntegralVO> integralGetById(@RequestBody IntegralPO integralPO){
        return sysIntegralService.integralGetById(integralPO);
    }

    @PostMapping("/personalRank")
    @ApiOperation("个人积分排行")
    @RequiresPermissions({"mini:integral:personalRank"})
    public ApiResponse<IntegralVO> integralPersonRank(@RequestBody IntegralPO integralPO){
        return sysIntegralService.integralPersonalRank(integralPO);
    }

    @PostMapping("/teamRank")
    @ApiOperation("小组积分排行")
    @RequiresPermissions({"mini:integral:teamRank"})
    public ApiResponse<IntegralVO> integralTeamRank(@RequestBody IntegralPO integralPO){
        return sysIntegralService.integralTeamRank(integralPO);
    }

}

